<!DOCTYPE html><html lang="zh-CN"><head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>moment(String) &#x7279;&#x6B8A;&#x683C;&#x5F0F; | Moment.js &#x6587;&#x6863;</title>
  <link rel="stylesheet" href="static/css/style.css">
  <link rel="shortcut icon" href="http://momentjs.cn/static/img/moment-favicon.png">
  <link rel="stylesheet" href="static/css/atom-one-light.min.css">
</head>
<body class="is-moment">
  <div class="hero hero-oneline">
    <div class="hero-centered">
      <h1>moment(String) &#x7279;&#x6B8A;&#x683C;&#x5F0F;</h1>
    </div>
  </div>
  <div id="api-section-__FILENAME__">
    <div id="content" class="clearfix">
  
      <div id="column1" data-id="__ID__" class="interior">
        <header>
          <!-- <h1>moment(String) 特殊格式</h1> -->
          <div id="gtoc">
            <ul>
              <!-- <li>v</li> -->
              <li>
                <a href="index.html#/parsing/special-formats/" name="toc">&#x8FD4;&#x56DE;&#x4E0A;&#x5C42;&#x6587;&#x6863;</a>
              </li>
              <li style="border: none;">
                <a href="javascript:window.open('https://github.com/momentjscn/moment-docs-cn/edit/master/moment/01-parsing/05-special-formats.md');" rel="nofollow" target="_blank">&#x63D0;&#x4EA4;&#x4FEE;&#x6539;</a>
              </li>
              <!-- <li>
                <a href="/search__SEARCH_PARAM__" name="toc">搜索</a>
              </li> -->
            </ul>
          </div>
          <hr>
        </header>

        <div id="biz_item"></div>
  
        <div id="apicontent">
          <div id="content_left">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment(String, moment.CUSTOM_FORMAT, [String], [Boolean]);
moment(String, moment.HTML_FMT.DATETIME_LOCAL, [String], [Boolean]); // &#x4ECE; 2.20.0 &#x5F00;&#x59CB;&#x3002;
moment(String, [..., moment.ISO_8601, ...], [String], [Boolean]);
</code></pre>

							</div>
<p><a href="javascript:window.open('http://nodejs.cn/s/eV6MeQ');" target="_blank" rel="nofollow">ISO-8601</a> &#x662F;&#x65F6;&#x95F4;&#x548C;&#x65F6;&#x957F;&#x663E;&#x793A;&#x7684;&#x6807;&#x51C6;&#x3002;
Moment &#x5DF2;&#x7ECF;&#x652F;&#x6301;&#x89E3;&#x6790; iso-8601 &#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x4F46;&#x662F;&#x53EF;&#x4EE5;&#x5728;&#x6784;&#x9020; moment &#x65F6;&#x5728;&#x683C;&#x5F0F;/&#x683C;&#x5F0F;&#x5217;&#x8868;&#x4E2D;&#x660E;&#x786E;&#x5730;&#x6307;&#x5B9A;&#x3002;</p>
<p>&#x8981;&#x6307;&#x5B9A; iso-8601 &#x89E3;&#x6790;&#xFF0C;&#x5219;&#x4F7F;&#x7528; <code>moment.ISO_8601</code> &#x5E38;&#x91CF;&#x3002;</p>
<pre><code class="language-javascript">moment(&quot;2010-01-01T05:06:07&quot;, moment.ISO_8601);
moment(&quot;2010-01-01T05:06:07&quot;, [&quot;YYYY&quot;, moment.ISO_8601]);
</code></pre>
<p>&#x4ECE; <strong>2.20.0</strong> &#x7248;&#x672C;&#x5F00;&#x59CB;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4EE5;&#x4E0B; HTML5 &#x683C;&#x5F0F;&#xFF1A;</p>
<table>
<thead>
<tr><th>&#x5E38;&#x91CF;</th><th>&#x683C;&#x5F0F;</th><th>&#x793A;&#x4F8B;</th><th>&#x8F93;&#x5165;&#x7C7B;&#x578B;</th></tr>
</thead>
<tbody>
<tr><td><code>moment.HTML5_FMT.DATETIME_LOCAL</code></td><td><code>YYYY-MM-DDTHH:mm</code></td><td>2017-12-14T16:34</td><td><code>&lt;input type=&quot;datetime-local&quot; /&gt;</code></td></tr>
<tr><td><code>moment.HTML5_FMT.DATETIME_LOCAL_SECONDS</code></td><td><code>YYYY-MM-DDTHH:mm:ss</code></td><td>2017-12-14T16:34:10</td><td><code>&lt;input type=&quot;datetime-local&quot; step=&quot;1&quot; /&gt;</code></td></tr>
<tr><td><code>moment.HTML5_FMT.DATETIME_LOCAL_MS</code></td><td><code>YYYY-MM-DDTHH:mm:ss.SSS</code></td><td>2017-12-14T16:34:10.234</td><td><code>&lt;input type=&quot;datetime-local&quot; step=&quot;0.001&quot; /&gt;</code></td></tr>
<tr><td><code>moment.HTML5_FMT.DATE</code></td><td><code>YYYY-MM-DD</code></td><td>2017-12-14</td><td><code>&lt;input type=&quot;date&quot; /&gt;</code></td></tr>
<tr><td><code>moment.HTML5_FMT.TIME</code></td><td><code>HH:mm</code></td><td>16:34</td><td><code>&lt;input type=&quot;time&quot; /&gt;</code></td></tr>
<tr><td><code>moment.HTML5_FMT.TIME_SECONDS</code></td><td><code>HH:mm:ss</code></td><td>16:34:10</td><td><code>&lt;input type=&quot;time&quot; step=&quot;1&quot; /&gt;</code></td></tr>
<tr><td><code>moment.HTML5_FMT.TIME_MS</code></td><td><code>HH:mm:ss.SSS</code></td><td>16:34:10.234</td><td><code>&lt;input type=&quot;time&quot; step=&quot;0.001&quot; /&gt;</code></td></tr>
<tr><td><code>moment.HTML5_FMT.WEEK</code></td><td><code>YYYY-[W]WW</code></td><td>2017-W50</td><td><code>&lt;input type=&quot;week&quot; /&gt;</code></td></tr>
<tr><td><code>moment.HTML5_FMT.MONTH</code></td><td><code>YYYY-MM</code></td><td>2017-12</td><td><code>&lt;input type=&quot;month&quot; /&gt;</code></td></tr>
</tbody>
</table>
					</div>
          <div id="content_right">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment(String, moment.CUSTOM_FORMAT, [String], [Boolean]);
moment(String, moment.HTML_FMT.DATETIME_LOCAL, [String], [Boolean]); // from 2.20.0
moment(String, [..., moment.ISO_8601, ...], [String], [Boolean]);
</code></pre>

							</div>
<p><a href="javascript:window.open('https://en.wikipedia.org/wiki/ISO_8601');" target="_blank" rel="nofollow">ISO-8601</a> is a standard for time and duration display. Moment already supports parsing iso-8601 strings, but this can be specified explicitly in the format/list of formats when constructing a moment.</p>
<p>To specify iso-8601 parsing use <code>moment.ISO_8601</code> constant.</p>
<pre><code class="language-javascript">moment(&quot;2010-01-01T05:06:07&quot;, moment.ISO_8601);
moment(&quot;2010-01-01T05:06:07&quot;, [&quot;YYYY&quot;, moment.ISO_8601]);
</code></pre>
<p>As of version <strong>2.20.0</strong>, the following HTML5 formats are available:</p>
<table>
<thead>
<tr><th>Constant</th><th>Format</th><th>Example</th><th>Input Type</th></tr>
</thead>
<tbody>
<tr><td><code>moment.HTML5_FMT.DATETIME_LOCAL</code></td><td><code>YYYY-MM-DDTHH:mm</code></td><td>2017-12-14T16:34</td><td><code>&lt;input type=&quot;datetime-local&quot; /&gt;</code></td></tr>
<tr><td><code>moment.HTML5_FMT.DATETIME_LOCAL_SECONDS</code></td><td><code>YYYY-MM-DDTHH:mm:ss</code></td><td>2017-12-14T16:34:10</td><td><code>&lt;input type=&quot;datetime-local&quot; step=&quot;1&quot; /&gt;</code></td></tr>
<tr><td><code>moment.HTML5_FMT.DATETIME_LOCAL_MS</code></td><td><code>YYYY-MM-DDTHH:mm:ss.SSS</code></td><td>2017-12-14T16:34:10.234</td><td><code>&lt;input type=&quot;datetime-local&quot; step=&quot;0.001&quot; /&gt;</code></td></tr>
<tr><td><code>moment.HTML5_FMT.DATE</code></td><td><code>YYYY-MM-DD</code></td><td>2017-12-14</td><td><code>&lt;input type=&quot;date&quot; /&gt;</code></td></tr>
<tr><td><code>moment.HTML5_FMT.TIME</code></td><td><code>HH:mm</code></td><td>16:34</td><td><code>&lt;input type=&quot;time&quot; /&gt;</code></td></tr>
<tr><td><code>moment.HTML5_FMT.TIME_SECONDS</code></td><td><code>HH:mm:ss</code></td><td>16:34:10</td><td><code>&lt;input type=&quot;time&quot; step=&quot;1&quot; /&gt;</code></td></tr>
<tr><td><code>moment.HTML5_FMT.TIME_MS</code></td><td><code>HH:mm:ss.SSS</code></td><td>16:34:10.234</td><td><code>&lt;input type=&quot;time&quot; step=&quot;0.001&quot; /&gt;</code></td></tr>
<tr><td><code>moment.HTML5_FMT.WEEK</code></td><td><code>YYYY-[W]WW</code></td><td>2017-W50</td><td><code>&lt;input type=&quot;week&quot; /&gt;</code></td></tr>
<tr><td><code>moment.HTML5_FMT.MONTH</code></td><td><code>YYYY-MM</code></td><td>2017-12</td><td><code>&lt;input type=&quot;month&quot; /&gt;</code></td></tr>
</tbody>
</table>
					</div>
          <div></div>
        </div>
      </div>
    </div>
  </div>
  
  <script src="static/js/highlight.min.js"></script>
  <script src="static/js/javascript.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
  <script>var _hmt = _hmt || []; (function () { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?7a7f78c805fbacc7e075d34f153031aa"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();</script>

  <style>
    .hero-centered {
      margin: 0;
          margin-left: 10px;
    }
#gtoc ul {
  list-style: none;
  margin-left: 0;
  line-height: 1.5rem;
  padding: 0;
}
#gtoc>ul>li {
  display: inline;
  border-right: 1px solid #000;
  margin-right: .4rem;
  padding-right: .4rem;
}
#gtoc>ul>li>a {
  color: #61b2a7;
}
#content_left {
  width: 49%;float: left;border-right: 1px solid #eee;    padding-right: 2%;
}
#content_right {
float: left;width: 48%;margin-left: 3%;
}
#column1 {
  padding: 0 2rem;
}
  </style>


</body></html>